﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;

namespace ProjectSem40701.Util
{
    public class SaveMark
    {
        /// <summary>
        /// Luu diem vao db
        /// </summary>
        /// <param name="mark">Diem</param>
        /// <param name="rid">Ma vong thi</param>
        /// <param name="userID">Ma thi sinh</param>
        public void saveMark(double mark, int rid, Guid userID)
        {
            MainDataset.UserRoundTableAdapters.tbl_UserRound_Select_All_AllowTest_By_UserIDTableAdapter dpUserRound
                = new MainDataset.UserRoundTableAdapters.tbl_UserRound_Select_All_AllowTest_By_UserIDTableAdapter();
            DataTable dttblUserRound = dpUserRound.Get_tbl_UserRound_Select_All_By_UserID_RoundID(userID, rid);
            if (dttblUserRound.Rows.Count > 0)
            {
                //Update
                dpUserRound.tbl_UserRound_Update_By_UserID_RoundID(mark, userID, DateTime.Now, rid);
            }
            else
            {
                //Insert
                dpUserRound.tbl_UserRound_Insert(userID, rid, mark, DateTime.Now, 0);
            }
        }
    }
}
